package com.yelin.taketitle;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class ImageUtils {
    public static Bitmap readBitmapFromFile(String filePath) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(filePath, options);

        options.inJustDecodeBounds = false;
        options.inSampleSize = 1;
        return BitmapFactory.decodeFile(filePath, options);
    }

    public static Bitmap readBitmapFromAsset(Resources res, int id) {
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeResource(res, id, options);

        options.inJustDecodeBounds = false;
        options.inSampleSize = 1;
        return BitmapFactory.decodeResource(res, id, options);
    }

}
